/*
 *	Name:	smeta_exploit.h
 *
 *	Purpose:
 *	Include file containing the function prototypes used in the exploitation of product
 *	metadata for purposes of calculating viewing and solar illumination angles. These
 *	functions operate on the SMETA data type defined in "smeta.h".
 */
#ifndef	_SMETA_EXPLOIT_H_
#define	_SMETA_EXPLOIT_H_

#include <time.h>
#include <limits.h>
#include "ias_odl.h"				/* IAS_OBJ_DESC definition                   */
#include "smeta.h"				/* Definition of SMETA structure             */

typedef struct META_FRAME
{
    int		band;				/* Band number                               */
    int		nlines;				/* Number of image lines                     */
    int		nsamps;				/* Number of image samples                   */
    int		code;				/* Projection code (1 = UTM or 6 = PS)       */
    int		zone;				/* Projection zone number                    */
    double	ul_x;				/* Upper left corner X coordinate            */
    double	ul_y;                           /* Upper left corner Y coordinate            */
    double	pixsize;			/* Pixel size in meters                      */
} META_FRAME;

int smeta_read(
    SMETA	*smeta,				/* Product metadata structure to load        */
    const char	*smeta_filename);		/* Input file name to read 	 	     */

int smeta_read_file_header(
    SMETA		*smeta,			/* Product metadata structure to load        */
    IAS_OBJ_DESC        *smeta_odl );		/* Product metadata ODL object               */

int smeta_read_projection(
    SMETA_SCENE_PROJ	*projection,		/* Projection structure to load              */
    IAS_OBJ_DESC        *smeta_odl );		/* Product metadata ODL object               */

int smeta_read_band_meta(
    SMETA_BAND          *band_smeta,            /* Product metadata structure to load        */
    IAS_OBJ_DESC        *smeta_odl );           /* Product metadata ODL object               */

/* variant for read_band_meta for L5TM and older */
int smeta_read_band_meta_ls(
    SMETA_BAND_LS          *band_smeta,            /* Product metadata structure to load        */
    IAS_OBJ_DESC        *smeta_odl );           /* Product metadata ODL object               */

int smeta_load_band_model(
    SMETA_BAND          *band_smeta );          /* Product metadata structure to load        */

/* variant for read_band_meta for L5TM and older */
int smeta_load_band_model_ls(
    SMETA		*smeta,                         /* Product metatdata structure to load */
    SMETA_BAND_LS          *band_smeta );          /* Product metadata structure to load        */

int meta_write_angfile(
    char		*root_filename,		/* Output root file name                     */
    short		*sat_zn,		/* Array of satellite zenith angles          */
    short		*sat_az,		/* Array of satellite azimuth angles         */
    short		*sun_zn,		/* Array of solar zenith angles              */
    short		*sun_az,		/* Array of solar azimuth angles             */
    META_FRAME		*frame );		/* Output image frame information            */

int delta_date(
  int			date1[3],		/* Base date year, month, day                */
  int			date2[3] );		/* Final date year, month, day               */

#endif
